package com.epoint.pjq.core.mqtt;

import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttMessage;

/**
 * 
 * @author lilin
 * @date 2016年10月19日 上午10:29:17
 * @annotation 消息回调处理
 */
public class SMP_MQTT_CallBack implements MqttCallback {

	@Override
	public void connectionLost(Throwable e) {
		SMP_MQTT_Bizlogic.sendLogBroadcast("连接丢失...");
		SMP_MQTT_Bizlogic.sendLogBroadcast(e.getMessage());

		if(SMP_MQTT_Service.isStarted){
			SMP_MQTT_Bizlogic.sendLogBroadcast("<connectionLost>正在重新连接...");
			new SMP_MQTT_ConnectionThread().start();
		}
	}

	@Override
	public void deliveryComplete(IMqttDeliveryToken arg0) {
		
	}

	@Override
	public void messageArrived(String arg0, MqttMessage arg1) throws Exception {
		SMP_MQTT_Bizlogic.dealMessage(arg1.toString());
	}
}
